package com.timeDeal.servlet;


import com.alibaba.druid.util.StringUtils;
import com.timeDeal.bean.JiaoyiQingqiuBean;
import com.timeDeal.bean.UserBean;
import com.timeDeal.bean.XuqiufabuBean;
import com.timeDeal.service.JiaoyiQingqiuServicce;
import com.timeDeal.service.XuqiuService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * Created by Administrator on 2016/7/24.
 */

public class TijiaoJIaoyiQingqiuServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, IOException, IOException {
        String  id =request.getParameter("id")  ;
        String  leixing =request.getParameter("leixing")  ;
        leixing = StringUtils.equals(leixing,null)?"xuqiufabu":leixing ;
        System.out.println(id);
        System.out.println(leixing);
        System.out.println("fffffffffffffffffffffffff");
        UserBean  loginuser  = (UserBean) request.getSession().getAttribute("USER") ;
        XuqiuService xuqiuService = new XuqiuService() ;
        JiaoyiQingqiuBean jiaoyiQingqiuBean = new JiaoyiQingqiuBean() ;
        JiaoyiQingqiuServicce jiaoyiQingqiuServicce   = new JiaoyiQingqiuServicce() ;
       jiaoyiQingqiuBean.setTijiaorenid(loginuser.getYonghuid());
        int xuqiuid = xuqiuService.getAxuquById(Integer.valueOf(id)).getJiafangid() ;

        jiaoyiQingqiuBean.setQingqiuduixiangid(xuqiuid);
        if(StringUtils.equals("xuqiufabu",leixing)){
            jiaoyiQingqiuBean.setXuqiufabuid(Integer.valueOf(id));
            jiaoyiQingqiuServicce.tijiaoJiaoYiQingqiu(jiaoyiQingqiuBean) ;
        }
        else {
            jiaoyiQingqiuBean.setShijianchushouid(Integer.valueOf(id));
            jiaoyiQingqiuServicce.tijiaoJiaoYiQingqiuByjq(jiaoyiQingqiuBean) ;
        }

            request.getRequestDispatcher("/user/zhujiemiangg.jsp").forward(request,response);

    }
}